package com.ler.yrmall.search.request;

import lombok.Data;

import java.io.Serializable;
import java.util.List;

/**
 * @author leron
 */
@Data
public class SpuSearchRequest implements Serializable {

    /**
     * 查询关键字
     */
    private String keyword;

    /**
     * 三级分类 id
     */
    private Long categoryId;

    /**
     * 排序
     */
    private Sort sort;

    /**
     * 是否有货 1 有 0 无
     */
    private Integer hasStock;

    /**
     * 品牌
     */
    private List<Long> brandIds;

    /**
     * 基本属性查询
     */
    private List<Attr> attrs;

    private Integer skuMinPrice;

    private Integer skuMaxPrice;

    private Integer pageNo = 1;


    public static class Sort implements Serializable {

        private String field;

        private String mode;

        public static final String ASC = "asc";

        public static final String DESC = "desc";

        public String getField() {
            return field;
        }

        public void setField(String field) {
            this.field = field;
        }

        public String getMode() {
            if (this.mode == null) {
                this.mode = ASC;
            }
            this.mode = this.mode.toLowerCase();
            if (!ASC.equals(this.mode) && !DESC.equals(this.mode)) {
                return ASC;
            }
            return mode;
        }

        public void setMode(String mode) {
            this.mode = mode;
        }
    }

    @Data
    public static class Attr implements Serializable {

        private Long attrId;

        private List<String> attrValues;

    }
}
